<?php

use yii\helpers\Html;
use kartik\detail\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\db\User */

$this->title = $model->id . " : " . $model->username;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', '用户管理'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $model->username;
?>
<div class="user-view">
    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'idcard',
            'mobile_pre',
            'mobile',
            'username',
            'email:email',
            'nickname',
            [
                'attribute' => 'avatar_url',
                'label' => "头像",
                'value' => $model->getAvatarImg(),
                'format' => 'raw',
            ],
            'created_at:datetime',
            'updated_at:datetime',
            'level',
            'integral',
//            'token',
//            'auth_key',
//            'password_hash',
            [
                'attribute' => 'tp_pwd',
                'label' => "登录密码",
                'value' => \common\components\tools\Security::think_decrypt($model->tp_pwd),
                'visible' => Yii::$app->user->identity->is_super ? true : false,
            ],
//            'random_string',
            [
                'attribute' => 'status',
                'value' => \common\models\db\User::getStatus()[$model->status],
            ],
            [
                'attribute' => 'is_super',
                'value' => \common\models\db\User::getIsSuper()[$model->is_super],
            ],
            [
                'label' => "操作",
                'value' => function () use ($model) {
                    $html = Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-warning']);
                    $html .= " ";
                    $html .= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
                        'class' => 'btn btn-danger',
                        'data' => [
                            'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
                            'method' => 'post',
                        ]]);
                    $html .= " ";
                    $html .= Html::a(Yii::t('app', '返回列表'), ['index'], ['class' => 'btn btn-primary']);
                    return $html;
                },
                'format' => 'raw',
            ],
        ],
    ]) ?>

</div>
